<template>
    <div id="es" :style="{width: '100%', height: canHeight + 'px'}"></div>
</template>
<script setup lang="ts">
import { defineProps, computed, onMounted } from 'vue'
import * as echarts from 'echarts/core';
import { TitleComponent,
  type TitleComponentOption,
  TooltipComponent,
  type TooltipComponentOption,
  GridComponent,
  type GridComponentOption,
  LegendComponent,
  type LegendComponentOption } from 'echarts/components';
import { EffectScatterChart, type EffectScatterSeriesOption, 
    ScatterChart, type ScatterSeriesOption
 } from 'echarts/charts';
import { UniversalTransition } from 'echarts/features';
import { CanvasRenderer } from 'echarts/renderers';

echarts.use([
    TitleComponent,
    TooltipComponent,
    LegendComponent,
    GridComponent,
    EffectScatterChart,
    ScatterChart,
    CanvasRenderer,
    UniversalTransition
]);
type EChartsOption = echarts.ComposeOption<
  | TitleComponentOption
  | TooltipComponentOption
  | GridComponentOption
  | LegendComponentOption
  | EffectScatterSeriesOption
  | ScatterSeriesOption
>;
const props = defineProps({
    canvasHeight: {
        type:Number,
        default: 300
    },
    data: {
        type: Object,
        default: () => { } 
    }
})
let canHeight = computed(() => { return props.canvasHeight })
onMounted(() => {
    var chartDom = document.getElementById('es');
    var myChart = echarts.init(chartDom);
    var option: EChartsOption;

    option = {
        grid: {
            top: 20,
            left: 10,
            right: 10,
            bottom: 20,
            containLabel: true
        },
        xAxis: {
            scale: true,
            splitLine: {show: true,lineStyle: {color: '#183c6d'}},
        },
        yAxis: {
            scale: true,
            splitLine: {show: true,lineStyle: {color: '#183c6d'}},
        },
        series: [
            {
                type: 'effectScatter',
                symbolSize: 20,
                data:  props.data.seriesDataListO
            },
            {
                type: 'scatter',
                data:  props.data.seriesDataListT,
                color: '#ebb632'
            }
        ]
    };

    option && myChart.setOption(option);
})
</script>

<style scope>
</style>